package com.cust.sky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cust.sky.entity.DishFlavor;
import com.cust.sky.mapper.DishFlavorMapper;
import com.cust.sky.service.DishFlavorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 菜品口味关系表 服务实现类
 * </p>
 *
 * @author lei
 * @since 2024-07-10
 */
@Service
public class DishFlavorServiceImpl extends ServiceImpl<DishFlavorMapper, DishFlavor> implements DishFlavorService {

    /**
     * 根据菜品id查询口味信息
     *
     * @param dishId
     * @return
     */
    @Override
    public List<DishFlavor> findByDishId(Long dishId) {
        LambdaQueryWrapper<DishFlavor> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DishFlavor::getDishId, dishId);
        List<DishFlavor> dishFlavors = baseMapper.selectList(wrapper);
        return dishFlavors;
    }

    @Override
    public void deleteByDishIds(List<Long> dishIds) {
        LambdaQueryWrapper<DishFlavor> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(DishFlavor::getDishId, dishIds);
        baseMapper.delete(wrapper);
    }

    @Override
    public void deleteByDishId(Long dishId) {
        LambdaQueryWrapper<DishFlavor> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DishFlavor::getDishId, dishId);
        baseMapper.delete(wrapper);
    }
}
